package com.ge.modules.api.service.impl;

import com.ge.modules.api.service.TbUserCardService;
import com.ge.modules.dao.TbRechargeOrderDao;
import com.ge.modules.dao.TbUserCardDao;
import com.ge.modules.dao.TbUserDao;
import com.ge.modules.entity.TbRechargeOrderEntity;
import com.ge.modules.entity.TbUser;
import com.ge.modules.entity.TbUserCardEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;


@Service
@Transactional
public class TbUserCardServiceImpl implements TbUserCardService {
    @Autowired
    private TbUserCardDao userCardDao;

    @Autowired
    private TbRechargeOrderDao tbRechargeOrderDao;

    @Autowired
    private TbUserDao userDao;

    @Override
    public TbUserCardEntity queryObject(Integer id) {
        return userCardDao.queryObject(id);
    }

    @Override
    public TbUserCardEntity queryByObject(TbUserCardEntity userCard) {
        return userCardDao.queryByObject(userCard);
    }

    @Override
    public List<TbUserCardEntity> queryList(Map<String, Object> map) {
        return userCardDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return userCardDao.queryTotal(map);
    }

    @Override
    public void save(TbUserCardEntity userCard) {
        userCardDao.save(userCard);
    }

    @Override
    public void update(TbUserCardEntity userCard) {
        userCardDao.update(userCard);
    }

    @Override
    public void delete(Integer id) {
        userCardDao.delete(id);
    }

    @Override
    public void deleteBatch(Integer[] ids) {
        userCardDao.deleteBatch(ids);
    }

    @Override
    public void updateSomeThing(TbUserCardEntity userCard, TbRechargeOrderEntity rechargeOrderEntity) {
        userCardDao.update(userCard);
        tbRechargeOrderDao.update(rechargeOrderEntity);
        //修改用户积分
//        TbUser tbUser = userDao.selectByPrimaryKey(rechargeOrderEntity.getUserId());
//        tbUser.setIntegral(tbUser.getIntegral() + rechargeOrderEntity.getMoney());
//        userDao.update(tbUser);
    }

}
